/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.scaroo.injectedgallery;

import org.scaroo.injectedgallery.objects.DefaultGallery;
import javax.annotation.PostConstruct;
import javax.ejb.Startup;
import javax.ejb.Stateless;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author alexandremazari
 */

public class GalleryProducer {

    @PersistenceContext EntityManager entityManager;

//    @PostConstruct
//    public void defaultGallery() {
//        Gallery gallery = new Gallery();
//        Photographer photographer = new Photographer();
//        photographer.setBio("You biography, intersting facts bout your work and life.");
//        photographer.setEmailAddress("you@you.com");
//        photographer.setName("Your Name");
//        photographer.setPhoneNumber("0139717093");
//
//        gallery.setPhotographer(photographer);
//        gallery.setName("Your Gallery");
//    entityManager.persist(gallery);
//
//
//    }


    @Produces @ApplicationScoped @Named("gallery")
    public Gallery getGallery() {
        
       // System.out.println("getGallery");
        Gallery gallery = null;
      //  gallery = entityManager.find(Gallery.class, Gallery.defaultId);

        if (gallery == null)
            gallery = new DefaultGallery();

        return gallery;
    }


}
